﻿using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using TVersityDotNet.HelperTypes;

namespace TVersityDotNet.Responses
{
    public class MediaSourceAddResponse : TVersityResponse
    {
        public int MediaSourceId { get; set; }

        public MediaSourceAddResponse(XDocument responseXmlDoc)
        {
            if (responseXmlDoc != null)
            {
                this.ParseMessage(responseXmlDoc);
            }
            else
            {
                this.ResponseSuccess = false;
                this.ResponseMessage = "Provided responseXml was null";
            }
        }

        public override void ParseMessage(XDocument responseXml)
        {
            base.ParseMessage(responseXml);
            if (this.ResponseSuccess)
            {
                XElement xElem = responseXml.Element("response");
                this.MediaSourceId = int.Parse(xElem.Value);
            }
        }
    }
}
